<?php
include('CetriDebila/connect.php');

$con = mysql_connect($hostname, $username, $password)
or die('Could not connect: ' . mysql_error());

mysql_select_db($database, $con);

$bool = mysql_select_db($database, $con);
if($bool == false)
{
	print = "Can't find $database";
}

$start = ($_REQUEST["start"] == NULL)? 0:$_REQUEST["start"];
$limit = ($_REQUEST["limit"] == NULL)? 200:$_REQUEST["limit"];

$query = "CALL dohvati_vozace()";

$query .= " ORDER BY IME ASC";
$query .= " LIMIT ".$start.",".$limit;

$result = mysql_query($query, $con);

$query_c = "SELECT VOZAC_ID, IME, PREZIME FROM vozaci";

$count_result = mysql_query($query_c, $con);
$total = mysql_num_rows($count_result);

if(mysql_num_rows($result) > 0)
{
	while($obj = mysql_fetch_object($result))
	{
		$arr[]=$obj;
	}
	
$myData = array('myInventory' => $arr, 'totalCount' => $total);
echo json_enconde($myData);
return;
exit();
}

else 
{
	$myData = array('myInventory' => '', 'totalCount' => '0');
	echo json_encode($myData);
	return
	exit();
}

?>


